const path = require('path');
const { name } = require('./package');
//
function resolve(dir) {
    return path.join(__dirname, dir);
}
//在vue.config.js中添加
const packageName = require('./package.json').name;
const port = 8093
const dev = process.env.NODE_ENV === 'development'

module.exports = {
    // outputDir: 'dist',
    // assetsDir: 'static',
    // filenameHashing: true,
    // tweak internal webpack configuration.
    // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
    // 配置publicPath，填写你本机的ip地址
    publicPath: dev ? `//192.168.5.46:${port}` : process.env.BASE_URL,
    lintOnSave: false,
    devServer: {
        // host: '0.0.0.0',
        // hot: true,
        // 关闭主机检查，使微应用可以被 fetch
        // disableHostCheck: true,
        port: 8093,
        // overlay: {
        //     warnings: false,
        //     errors: true,
        // },
        // 配置跨域请求头，解决开发环境的跨域问题
        headers: {
            'Access-Control-Allow-Origin': '*',
        },
        //Proxy: {
        // '/api': {// 子应用1服务
        //     target: process.env.VUE_APP_API_URL,
        //     changeOrigin: true,
        //     pathRewrite: {
        //         '^/api': ''
        //     }
        // },
        //}
    },
    // 自定义webpack配置
    configureWebpack: {
        resolve: {
            alias: {
                // "@": path.resolve(__dirname, "src"),
                '@': resolve('src'),
            },
        },
        output: {
            // publicPath: `//localhost:${port}`,
            // 微应用的包名，这里与主应用中注册的微应用名称一致
            library: `${packageName}-[name]`,
            // 把子应用打包成 umd 库格式
            libraryTarget: 'umd',
            // 按需加载相关，设置为 webpackJsonp_VueApp 即可
            jsonpFunction: `webpackJsonp_${packageName}`,
            globalObject: 'window',
        },
    },
};

